package com.ruoyi.project.drug.service.impl;

import com.ruoyi.project.drug.domain.Drug;
import com.ruoyi.project.drug.mapper.DrugMapper;
import com.ruoyi.project.drug.service.IDrugService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class DrugServiceImpl implements IDrugService {
    @Autowired
    private DrugMapper drugMapper;

    @Override
    public List<Drug> findDrugs(Drug drug) {
        return drugMapper.selectDrugs(drug);
    }

    @Override
    public int insertDrug(Drug drug) {
        drug.setCreateTime(new Date());
        return drugMapper.newDrug(drug);
    }

    @Override
    public Drug selectDrug(Long drugId) {
        return drugMapper.findDrug(drugId);
    }

    @Override
    public int alterDrug(Drug drug) {
        return drugMapper.editDrug(drug);
    }

    @Override
    public int removeDrugs(Long[] drugIds) {
        return drugMapper.dropDrugs(drugIds);
    }
}

